package com.idis.managerApp.controller;

import com.idis.common.base.BaseController;
import com.idis.entity.Contact;
import com.idis.service.ContactService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Ming on 2018/2/7.
 */

/**
 * 联系方式Api
 */
@RestController
@RequestMapping("/api/admin/contact")
@Api(tags = "联系方式接口")
public class ContactController extends BaseController{

    @Autowired
    ContactService contactService;

    @ApiOperation("获取联系方式")
    @GetMapping("/all")
    public Map getAll(){
        return sendDate(contactService.findAll());
    }

    @ApiOperation("更新联系方式")
    @PostMapping("/update")
    public Map update(@ApiParam(value = "联系方式对象,picture为图像的URL")Contact contact){
        Map map=new HashMap();
        if(contact.getId().equals("")){
            sendNull(map);
            return map;
        }
        addResult(map, String.valueOf(contactService.update(contact)));
        addMessage(map,"修改成功");
        return map;
    }
}
